package v1

import (
	"gin-vue-admin/global"
    "gin-vue-admin/model"
    "gin-vue-admin/model/request"
    "gin-vue-admin/model/response"
    "gin-vue-admin/service"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

// @Tags UserIndexTop
// @Summary 创建UserIndexTop
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.UserIndexTop true "创建UserIndexTop"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /userIndexTop/createUserIndexTop [post]
func CreateUserIndexTop(c *gin.Context) {
	var userIndexTop model.UserIndexTop
	_ = c.ShouldBindJSON(&userIndexTop)
	if err := service.CreateUserIndexTop(userIndexTop); err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
		response.FailWithMessage("创建失败", c)
	} else {
		response.OkWithMessage("创建成功", c)
	}
}

// @Tags UserIndexTop
// @Summary 删除UserIndexTop
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.UserIndexTop true "删除UserIndexTop"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /userIndexTop/deleteUserIndexTop [delete]
func DeleteUserIndexTop(c *gin.Context) {
	var userIndexTop model.UserIndexTop
	_ = c.ShouldBindJSON(&userIndexTop)
	if err := service.DeleteUserIndexTop(userIndexTop); err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
		response.FailWithMessage("删除失败", c)
	} else {
		response.OkWithMessage("删除成功", c)
	}
}

// @Tags UserIndexTop
// @Summary 批量删除UserIndexTop
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除UserIndexTop"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /userIndexTop/deleteUserIndexTopByIds [delete]
func DeleteUserIndexTopByIds(c *gin.Context) {
	var IDS request.IdsReq
    _ = c.ShouldBindJSON(&IDS)
	if err := service.DeleteUserIndexTopByIds(IDS); err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
		response.FailWithMessage("批量删除失败", c)
	} else {
		response.OkWithMessage("批量删除成功", c)
	}
}


// @Tags UserIndexTop
// @Summary 更新UserIndexTop
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.UserIndexTop true "更新UserIndexTop"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /userIndexTop/updateUserIndexTop [put]
func UpdateUserIndexTop(c *gin.Context) {
	var userIndexTop model.UserIndexTop
	_ = c.ShouldBindJSON(&userIndexTop)
	if err := service.UpdateUserIndexTop(userIndexTop); err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
		response.FailWithMessage("更新失败", c)
	} else {
		response.OkWithMessage("更新成功", c)
	}
}

// @Tags UserIndexTop
// @Summary 用id查询UserIndexTop
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.UserIndexTop true "用id查询UserIndexTop"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /userIndexTop/findUserIndexTop [get]
func FindUserIndexTop(c *gin.Context) {
	var userIndexTop model.UserIndexTop
	_ = c.ShouldBindQuery(&userIndexTop)
	if err, reuserIndexTop := service.GetUserIndexTop(userIndexTop.ID); err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
		response.FailWithMessage("查询失败", c)
	} else {
		response.OkWithData(gin.H{"reuserIndexTop": reuserIndexTop}, c)
	}
}

// @Tags UserIndexTop
// @Summary 分页获取UserIndexTop列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.UserIndexTopSearch true "分页获取UserIndexTop列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /userIndexTop/getUserIndexTopList [get]
func GetUserIndexTopList(c *gin.Context) {
	var pageInfo request.UserIndexTopSearch
	_ = c.ShouldBindQuery(&pageInfo)
	if err, list, total := service.GetUserIndexTopInfoList(pageInfo); err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
        response.FailWithMessage("获取失败", c)
    } else {
        response.OkWithDetailed(response.PageResult{
            List:     list,
            Total:    total,
            Page:     pageInfo.Page,
            PageSize: pageInfo.PageSize,
        }, "获取成功", c)
    }
}
